import ajax from './request.config'
//角色管理
export const getRoleTable = (pageSize, pageNumber) => ajax.get('/role/list', { params: { pageSize, pageNumber } })
export const saveRole = ({ uuid, names }) => ajax.post('/role/save', { uuid, names })
export const deleteRole = uuid => ajax.post('/role/delete', { uuid })
export const getRolePowerTree = moduleids => ajax.get('/role/getAllOperator', { params: { moduleids } })
export const getSelectedTree = uuid => ajax.get('/role/getOperator', { params: { uuid } })
export const getSaveOperator = ({ operatorTree, uuid }) => ajax.post('/role/saveOperator', { operatorTree, uuid })

//分组管理
export const getRoleGroup = (pageNumber, pageSize) => ajax.get('/group/list', { params: { pageNumber, pageSize } })
export const saveGroup = ({ uuid, names, roleUuid }) => ajax.post('/group/save', { uuid, names, roleUuid })
export const getAllRole = () => ajax.get('/group/roleSelect')
export const deleteGroup = uuid => ajax.post('/group/delete', { uuid })

//操作员
export const getOperatorTable = ({
    loginName,
    loginType,
    belongedTo,
    startTime,
    endTime,
    pageSize,
    pageNumber
}) => ajax.get('/usermanage/list', {
    params: {
        loginName,
        loginType,
        belongedTo,
        startTime,
        endTime,
        pageSize,
        pageNumber
    }
})
export const operatorAllCondition = node_type => ajax.get('/instmanage/allBelonged', { params: { node_type } })
export const deleteOperator = uuid => ajax.post('/usermanage/delete', { uuid })
export const changePassword = ({ uuid, password }) => ajax.post('/usermanage/resetPwd', { uuid, password })
export const getServiceAll = () => ajax.get('/servicemanager/allService')
export const getAllGroup = () => ajax.get('/usermanage/setGroups')
export const saveOperator = ({
    mobile,
    name,
    user_type,
    password,
    group_uuid,
    inst_uuid
}) => ajax.post('/usermanage/save', {
    mobile,
    name,
    user_type,
    password,
    group_uuid,
    inst_uuid
})

//子管理员
export const getSubAdminsTable = (pageSize, pageNumber) => ajax.get('/subadministrator/list', { params: { pageNumber, pageSize } })
export const deleteSubadmins = uuid => ajax.post('/subadministrator/delete', { uuid })
export const mobilepd = mobile => ajax.get('/subadministrator/mobile', { params: { mobile } })
export const saveSubAdmins = ({
        uuid,
        mobile,
        name,
        instUuid,
        deptUuid,
        province,
        city,
        district,
        password,
        authority,
        roleManager
    }) => ajax.post('/subadministrator/save', {
        uuid,
        mobile,
        name,
        instUuid,
        deptUuid,
        province,
        city,
        district,
        password,
        authority,
        roleManager
    })
    //APP模块
export const getAppModuleTable = ({ pageNumber, pageSize }) => ajax.get('/appmodule/list', { params: { pageNumber, pageSize } })
export const deleteAppModule = uuid => ajax.post('/appmodule/delete', { uuid })
export const saveAppModule = ({
        uuid,
        module_name,
        module_event_code,
        comment,
        image_url,
        doubled_image_url
    }) => ajax.post('/appmodule/save', {
        uuid,
        module_name,
        module_event_code,
        comment,
        image_url,
        doubled_image_url
    })
    //APP版本
export const getVersionTable = (appType, pageNumber, pageSize) => ajax.get('/appversion/list', { params: { appType, pageNumber, pageSize } })
export const getVerOption = appType => ajax.get('/appversion/forceUpdate', { params: { appType } })
export const changeVesion = uuid => ajax.post('/appversion/updateVersion', { uuid })
export const saveAppVer = ({
    uuid,
    appType,
    lastest_version,
    content,
    time
}) => ajax.post('/appversion/saveVersion', {
    uuid,
    appType,
    lastest_version,
    content,
    time
})

//服务商管理
export const getMyServiceList = () => ajax.get('/facilitator/getServicesData')
export const deleteService = uuid => ajax.post('/facilitator/deletePartnerService', { uuid })
export const getMyProvideList = () => ajax.get('/facilitator/getSupplierData')
export const deleteProvide = uuid => ajax.post('/facilitator/deletePartnerSupplier', { uuid })
    //维修配置
export const getRCfg = () => ajax.get('/maintenance/module')
export const saveRCfg = ({
        uuid,
        process_distance,
        time_max_distribute,
        time_max_take_order,
        time_max_process
    }) => ajax.post('/maintenance/partnerWarningSave', {
        uuid,
        process_distance,
        time_max_distribute,
        time_max_take_order,
        time_max_process
    })
    //巡检配置
export const getInspTable = (pageNumber, pageSize) => ajax.get('/inspectionConfigure/inspectionlist', { params: { pageNumber, pageSize } })
export const getNoInspTable = (partnerCode, pageNumber, pageSize) => ajax.get('/inspectionConfigure/gotoAddInspection', { params: { partnerCode, pageNumber, pageSize } })
export const saveInspTemp = (partnerCode, inspection_name) => ajax.post('/inspectionConfigure/inspectionAdd', { partnerCode, inspection_name })
export const deleteInspTemp = uuid => ajax.post('/inspectionConfigure/inspectionDelete', { uuid })

export const getOffCof = () => ajax.get('/officeConfigure/officeList')
export const saveOffCof = (partnerCode, officeForecast) => ajax.post('/officeConfigure/saveOfficeForecast', { partnerCode, officeForecast })

export const getPZCof = () => ajax.get('/credentialConfigure/credentialList')
export const savePZCof = (partnerCode, credentialForecast, approverNum) => ajax.post('/credentialConfigure/saveCredentialForecast', { partnerCode, credentialForecast, approverNum })